# To change this template, choose Tools | Templates
# and open the template in the editor.

def GraphicsPipe():
        pipe = base.pipe.getDisplayInformation()
        l = pipe.getTotalDisplayModes()
        minmax = []
        minmax.append([pipe.getDisplayModeWidth(0),pipe.getDisplayModeHeight(0)])
        minmax.append([pipe.getDisplayModeWidth(l-1),pipe.getDisplayModeHeight(l-1)])
        #create resoltuion mode list
        base.res = []
        base.bpp = []
        base.hz = []
        for i in range(l):
            if str([pipe.getDisplayModeWidth(i),pipe.getDisplayModeHeight(i)]) not in base.res:
                    base.res.append(str([pipe.getDisplayModeWidth(i),pipe.getDisplayModeHeight(i)]))
            if pipe.getDisplayModeRefreshRate(i) not in base.hz:
                base.hz.append(pipe.getDisplayModeRefreshRate(i))
            if pipe.getDisplayModeBitsPerPixel(i) not in base.bpp:
                base.bpp.append(pipe.getDisplayModeBitsPerPixel(i))
        return minmax
def Load():
    rList = []
    try:
        f = open("config.xml", "r")
        text = f.readlines()
        for n in range(len(text)):
            newline = str(text[n]).replace("\n","")
            if "ip" in newline:
                rList.append(newline.replace("ip=",""))
            if "width" in newline:
                rList.append(newline.replace("width=",""))
            if "height" in newline:
                rList.append(newline.replace("height=",""))
            if "fullscreen" in newline:
                rList.append(newline.replace("fullscreen=",""))
            if "shadows" in newline:
                rList.append(newline.replace("shadows=",""))
            if "shaders" in newline:
                rList.append(newline.replace("shaders=",""))
            if "vsync" in newline:
                rList.append(newline.replace("vsync=",""))
        f.close()
    except IOError as e:
        rList = ["ip=127.0.0.1","width=1024","height=768","fullscreen=1","shadows=0","shaders=0","vsync=0"]
        f = open('config.xml','w')
        for n in range(len(rList)):
            f.write(rList[n]+"\n")
        f.close()
        return 0
    return rList
                          


